# ECDLP
CXX=g++

PVM_ROOT ?= /usr/lib/pvm3/
PVM_ARCH ?= LINUX

CXXFLAGS= -Wall -fno-exceptions -O2 -D_DEBUG
#CXXFLAGS= -Wall -fno-exceptions -g -D_DEBUG
#LDFLAGS= -pg

INCDIRS += -I../miracl/ -I$(PVM_ROOT)/include/
LIBDIRS += -L../miracl/ -L$(PVM_ROOT)/lib/$(PVM_ARCH)/

MIRLIBS += -lmiracl
PVMLIBS += -lpvm3

OBJS     = CECContext.o CCmdLineParser.o CRhoAlgCommon.o CLambdaAlg.o CRhoBrentAlg.o CRhoFloydAlg.o CRhoTabAlg.o CRhoTable.o CLambdaTable.o miraclExtensions.o
PVM_OBJS = CRhoBrentPvmAlg.o CPvmCommands.o CPvmMasterCommands.o CPvmSlaveCommands.o


all: ecdlp_tester ecdlp_master ecdlp_slave


ecdlp_tester: $(OBJS) main_tester.o
	$(CXX) $(LDFLAGS) $(LIBDIRS) -o $@ $^ $(MIRLIBS)   

ecdlp_master: $(OBJS) $(PVM_OBJS) main_master.o
	$(CXX) $(LDFLAGS) $(LIBDIRS) -o $@ $^ $(MIRLIBS) $(PVMLIBS)

ecdlp_slave: $(OBJS) $(PVM_OBJS) main_slave.o
	$(CXX) $(LDFLAGS) $(LIBDIRS) -o $@ $^ $(MIRLIBS) $(PVMLIBS) 

main_%.o: main_%.cpp CTimer.hpp 
	$(CXX) $(CXXFLAGS) $(INCDIRS) -c $< -o $@

%.o: %.cpp %.hpp
	$(CXX) $(CXXFLAGS) $(INCDIRS) -c $< -o $@


clean: 
	rm -f $(OBJS) *.o ecdlp_tester ecdlp_master ecdlp_slave

install:
	mkdir -p ~/pvm3/bin/$(PVM_ARCH)/
	mkdir -p ~/pvm3/bin/$(PVM_ARCH)/curves/
	cp ecdlp_master ecdlp_slave ~/pvm3/bin/$(PVM_ARCH)/
	cp -r curves/*.ecs ~/pvm3/bin/$(PVM_ARCH)/curves/

uninstall:
	rm -rf ~/pvm3/bin/$(PVM_ARCH)/ecdlp_*
	rm -rf ~/pvm3/bin/$(PVM_ARCH)/curves

# Formatovanie zdrojovych kodov pomocou programu AStyle	
astyle:
	astyle --indent=spaces=4 \
         --brackets=attach \
         --indent-switches \
         --pad=oper \
         --convert-tabs \
         --indent-preprocessor \
         --one-line=keep-blocks \
         --brackets=break-closing \
         --unpad=paren \
         --suffix=none \
         *.cpp *.hpp



